<template>
	<view class="mainpadding block">
		<!-- 提现规则 -->
		<u-popup :show="show" @close="close" mode="center" :round="10">
			<view class="mainpadding" >
				<view class="bigtext xiaohei fonweight" style="width:580rpx;">{{systeminfo.withdrawal_des}}</view>
				<view class="flexright margin_top6">
					<view class="sanshier xiaohui fonweight margin_right7" @click="close">取消</view>
					<view class="sanshier xiaolan fonweight" @click="close">确定</view>
				</view>
			</view>
		</u-popup>
		<view class="ffffff radius">
			<view class="lanbox flexbetween">
				<view class="">
					<view class="flexleft">
						<view class="strongtext fonweight xiaobai margin_right1">可提现金币</view>
						<u-icon name="question-circle" color="#9AB6FF" size="18" @click="show = true"></u-icon>
					</view>
					<view class="margin_top1 fonweight xiaobai" style="font-size: 70rpx;">{{userInfo.jb_num}}</view>
				</view>
			</view>
			<view class="" style="padding: 42rpx 30rpx;">
				<view class="xiaohui strongtext fonweight">开始提现</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="flexleft">
						<view class="sishi fonweight xiaohei">￥</view>
						<input type="digit" v-model="jb_num">
					</view>
					<view class="xiaolan strongtext " @click="jb_num = userInfo.jb_num">全部提现</view>
				</view>
				<!-- <view class="xiaohui strongtext margin_top">10金币=1元，最低提现10金币</view> -->
			</view>
		</view>
		<view class="ffffff mainpadding radius margin_top">
			<view class="xiaohui strongtext fonweight">提现至</view>
			<!-- <view class="flexbetween xiahuaxian margin_top">
				<view class="xiaohei ershiba fonweight">银行卡开户行</view>
				<input type="text" placeholder="请输入银行卡开户行" class="textright">
			</view>
			<view class="flexbetween xiahuaxian margin_top">
				<view class="xiaohei ershiba fonweight">银行卡账户</view>
				<input type="text" placeholder="请输入银行卡账户" class="textright">
			</view> -->
			<!-- <view class=" flexbetween mainpadding margin_top" :class="pay_type==10?'yixzbox':'weixbox'" @click="pay_type=10">
				<view class="flexleft">
					<view class="margin_right1">
						<u-icon name="weixin-circle-fill" color="#09BB07" size="28"></u-icon>
					</view>
					<view class="sanshier">微信</view>
				</view>
				<view class="weixz margin_right1" v-if="pay_type!=10"></view>
				<view class="margin_right1" v-if="pay_type==10">
					<u-icon name="checkmark-circle-fill" color="#2361FF" size="19"></u-icon>
				</view>
			</view> -->
			<view class="flexbetween mainpadding margin_top" :class="pay_type==20?'yixzbox':'weixbox'"
				@click="pay_type=20">
				<view class="flexleft">
					<view class="margin_right1">
						<u-icon name="zhifubao-circle-fill" color="#06B4FD" size="28"></u-icon>
					</view>
					<view class="sanshier">支付宝</view>
				</view>
				<view class="weixz margin_right1" v-if="pay_type!=20"></view>
				<view class="margin_right1" v-if="pay_type==20">
					<u-icon name="checkmark-circle-fill" color="#2361FF" size="19"></u-icon>
				</view>
			</view>
			<view class="bigbtn margin_top6" @click="submit">申请提现</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				userInfo:{},
				systeminfo:{},
				jb_num:"",
				pay_type: 20, //支付方式:10=微信,20=支付宝
				openid:""
			}
		},
		onLoad() {
			this.userinfomsg()
			this.system()
		},
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			system() {
				httpRequest.request('/api/index/getConfigInfo', 'GET', {}).then(res => {
					this.systeminfo = res.data
				})
			},
			submit() {
				let data = {
					jb_num: this.jb_num,
					type: this.pay_type==10?1:2,
					openid:this.openid
				}
				if(this.jb_num==""){
					httpRequest.toast("请输入提现金币数量")
				}
				if(this.pay_type==20 && !this.userInfo.ali_account){
					httpRequest.toast("请完善支付宝信息")
					setTimeout(()=>{
						uni.navigateTo({
							url:"/pages_mypage/xiugaizfb"
						})
					},1000)
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/addWithdrawal', 'GET',data).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			},
			close() {
				this.show = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.jinbi {
		width: 32rpx;
		height: 32rpx;
	}

	.baibtn1 {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #7DA2FF;
		width: 154rpx;
		height: 64rpx;
		background: #FFFFFF;
		border-radius: 32rpx;
	}

	.lanbox {
		padding: 42rpx 30rpx;
		background: linear-gradient(90deg, #2361FF 0%, #8AABFF 100%);
		border-radius: 20rpx 20rpx 0rpx 0rpx;
	}

	.block {
		background: #F9F9F9;
		min-height: calc(100vh - 100rpx);
		height: auto;
	}
	.weixbox {
		background: #FBFCFF;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		border: 1rpx solid #FBFCFF;
	}
	
	.yixzbox {
		background: rgba(35, 97, 255, 0.1);
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		opacity: 1;
		border: 1rpx solid #2361FF;
	}
</style>